﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;
namespace IHISCETeim.BLL
{
    public class UQualityQuestionnaireController : BaseController
    {
        public static int Add(UQualityQuestionnaireInfo obj)
        {
            return UQualityQuestionnaireDAL.Add(obj);
        }
        public static bool Delete(int UQQID)
        {
            return UQualityQuestionnaireDAL.Delete(UQQID);
        }
        public static UQualityQuestionnaireInfo GetByUQQID(int UQQID)
        {
            return CBO.FillObject<UQualityQuestionnaireInfo>( UQualityQuestionnaireDAL.GetByUQQID(UQQID));
        }
        public static DataTable GetPagination(string SerialNumber, string CustomerName, string AgentName, string SurveyDateFrom, string SurveyDateTo, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return UQualityQuestionnaireDAL.GetPagination(SerialNumber, CustomerName, AgentName, SurveyDateFrom, SurveyDateTo, PageIndex, PageSize, Sort, ref  TotalCount);
        }
        public static bool Update(UQualityQuestionnaireInfo obj)
        {
            return UQualityQuestionnaireDAL.Update(obj);
        }

        public static List<UQualityListInfo> UQualityList_GetByUQQID(int UQQID)
        {
            return CBO.FillCollection<UQualityListInfo>(UQualityQuestionnaireDAL.UQualityList_GetByUQQID(UQQID));
        }
        /// <summary>
        /// 所有品质
        /// </summary>
        /// <returns></returns>
        public static List<UQualityTempleteInfo> UQualityTemplete_GetALL()
        {
            List<UQualityTempleteInfo> all=DC.Get<List<UQualityTempleteInfo>>(UQualityTempleteALLKey);
            if (all==null)
            {
                all = CBO.FillCollection<UQualityTempleteInfo>(UQualityQuestionnaireDAL.UQualityTemplete_GetALL());
                DC.Add(UQualityTempleteALLKey, all);
            }
            return all;
        }

        public static List<UQualityTempleteInfo> UQualityTemplete_GetByParId(int ParId,int QTType)
        {
            List<UQualityTempleteInfo> all = UQualityTemplete_GetALL();
            return all.FindAll(e => e.ParId == ParId && e.QTType==QTType);
        }

        public static DataTableCollection GetReport(string fromdate, string todate)
        {
            return UQualityQuestionnaireDAL.GetReport(fromdate, todate);
        }

    }
}
